var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("Util"),
l = t("Global"),
c = t("BoxGetView"),
d = t("HallConstant"),
h = cc._decorator,
p = h.ccclass,
u = h.property,
f = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.node_multiple = null,
        e.lab_Num = null,
        e.lab_getTimes = null,
        e.btn_get = null,
        e.btn_video = null,
        e.btn_nextDay = null,
        e.icon_item = null,
        e.probar_openNum = null,
        e.label_proNum = null,
        e.node_moust = null,
        e.videoTab = l.VideoTab.Unknown,
        e._shopView = null,
        e._index = 0,
        e._itemData = null,
        e._getTimes = 0,
        e
    }
    return n(e, t),
    e.prototype.init = function(t) {
        this._shopView = t
    },
    e.prototype.updateItem = function(t, e, o) {
        this._index = t,
        this._itemData = e,
        this._getTimes = o,
        this.refreshPro(),
        this.lab_getTimes.string = e.maxTimes - o + "/" + e.maxTimes,
        "gold" == e.type || "diamond" == e.type ? (o >= e.freeTimes ? this.lab_Num.string = "" + s.Util.transformGoldStr(e.num * this._itemData.multiple) : this.lab_Num.string = "" + s.Util.transformGoldStr(e.num), o >= e.maxTimes ? (this.btn_get.node.active = !1, this.btn_video.node.active = !1, this.node_multiple.active = !0, this.btn_nextDay.node.active = !0) : o >= e.freeTimes ? (this.btn_get.node.active = !1, this.node_multiple.active = !0, this.btn_nextDay.node.active = !1, this.btn_video.node.active = !0) : (this.btn_get.node.active = !0, this.node_multiple.active = !1, this.btn_video.node.active = !1, this.btn_nextDay.node.active = !1)) : o >= e.maxTimes ? (this.btn_get.node.active = !1, this.btn_video.node.active = !1, this.btn_nextDay.node.active = !0) : o >= e.freeTimes ? (this.btn_get.node.active = !1, this.btn_nextDay.node.active = !1, this.btn_video.node.active = !0) : (this.btn_get.node.active = !0, this.btn_video.node.active = !1, this.btn_nextDay.node.active = !1),
        this.btn_video.node.active && this.exposure()
    },
    e.prototype.exposure = function() {
        switch (this.node.name) {
            case "shopItem1":
            case "shopItem2":
                this.videoTab = l.VideoTab.Unknown;
            break;
            case "shopItem3":
                this.videoTab = l.VideoTab.dim5;
            break;
            case "shopItem4":
                this.videoTab = l.VideoTab.dim6;
            break;
            case "shopItem5":
                this.videoTab = l.VideoTab.dim7;
        }
        s.Util.videoExposure(this.videoTab)
    },
    e.prototype.getIconNode = function() {
        return this.icon_item.parent
    },
    e.prototype.refreshPro = function() {
        switch (this._itemData.type) {
            case "box" + c.Box_Type.common: this.totalOpenNum = 3,
            this.curOpenNum = r.default.openShopCommonBoxNum;
            break;
            case "box" + c.Box_Type.middle: this.totalOpenNum = 5,
            this.curOpenNum = r.default.openShopEpicBoxNum;
            break;
            case "box" + c.Box_Type.senior: this.totalOpenNum = 10,
            this.curOpenNum = r.default.openShopLegendBoxNum;
            break;
            default: this.totalOpenNum = 0,
            this.curOpenNum = 0;
        }
        this.totalOpenNum && (this.curOpenNum + 1 === this.totalOpenNum ? this.node_moust.active = !0 : this.node_moust.active = !1, this.label_proNum.string = this.curOpenNum + " / " + this.totalOpenNum, this.probar_openNum.progress = this.curOpenNum / this.totalOpenNum)
    },
    e.prototype.onBtnGet = function() {
        this._shopView.playAudio(d.Audio_ID.btn_click),
        this._shopView.onGet(this._index, this._itemData.type, this._itemData.num, this.refreshPro.bind(this))
    },
    e.prototype.onBtnVideo = function() {
        this._shopView.playAudio(d.Audio_ID.btn_click);
        var t = this._itemData.num;
        this._getTimes >= this._itemData.freeTimes && (t *= this._itemData.multiple),
        this._shopView.onVideo(this._index, this._itemData.type, t, this.videoTab, this.refreshPro.bind(this))
    },
    a([u(cc.Node)], e.prototype, "node_multiple", void 0),
    a([u(cc.Label)], e.prototype, "lab_Num", void 0),
    a([u(cc.Label)], e.prototype, "lab_getTimes", void 0),
    a([u(cc.Button)], e.prototype, "btn_get", void 0),
    a([u(cc.Button)], e.prototype, "btn_video", void 0),
    a([u(cc.Button)], e.prototype, "btn_nextDay", void 0),
    a([u(cc.Node)], e.prototype, "icon_item", void 0),
    a([u(cc.ProgressBar)], e.prototype, "probar_openNum", void 0),
    a([u(cc.Label)], e.prototype, "label_proNum", void 0),
    a([u(cc.Node)], e.prototype, "node_moust", void 0),
    a([p], e)
} (cc.Component);
o.default = f